import create from 'zustand';

export interface GetCommonState {
    currenciesList: [];
    currency: string;
    navOpen:boolean,
    isAutoConnect:boolean,
    greenHandsDo:boolean,
    CSVDo:boolean,
    greenHands:boolean,
    greenHandsLV:number,
    CSVLV:number,

    setCurrenciesList: (list: []) => void;
    setCurrency: (currency: string) => void;
    setNavOpen: (b: boolean) => void;
    setAuto: (b: boolean) => void;
    setGreenHandsDo: (b: boolean) => void;
    setCSVDo: (b: boolean) => void;
    setGreenHands: (b: boolean) => void;
    setGreenHandsLV: (b: number) => void;
    setCSVLV: (b: number) => void;

    clear: () => void;
}
export const useGetCommonStateStore = create<GetCommonState>((set) => ({
    currenciesList: [],
    currency: "USD",
    navOpen: true,
    isAutoConnect: false,
    greenHandsDo: true,
    CSVDo: true,
    greenHands: false,
    greenHandsLV: 0,
    CSVLV:-1,

    setCurrenciesList(list: []) {
        set(() => ({
            currenciesList:list,
        }));
    },

    setCurrency(currency: string) {
        set(() => ({
            currency:currency,
        }));
    },
    setNavOpen(b: boolean) {
        set(() => ({
            navOpen:b,
        }));
    },
    setAuto(b: boolean) {
            set(() => ({
                isAutoConnect:b,
            }));
    },
    setGreenHands(b: boolean) {
            set(() => ({
                greenHands:b,
            }));
    },
    setGreenHandsDo(b: boolean) {
            set(() => ({
                greenHandsDo:b,
            }));
    },
    setCSVDo(b: boolean) {
            set(() => ({
                CSVDo:b,
            }));
    },
    setGreenHandsLV(b: number) {
        console.log("setGreenHandsLV=",b)
            set(() => ({
                greenHandsLV:b,
            }));
    },
    setCSVLV(b: number) {
            set(() => ({
                CSVLV:b,
            }));
    },



    clear() {
        set(() => ({
            currenciesList: [],
            currency: "USD",
            navOpen: true,
            isAutoConnect: false,
            greenHands: false,
        }));
    }
}));
